﻿using System.Windows.Forms;
public class DoubleBufferPanel : Panel
{
  public DoubleBufferPanel()
  {
    this.TabStop = true;
    // Set the value of the double-buffering style bits to true.
    this.SetStyle(ControlStyles.DoubleBuffer |
      ControlStyles.UserPaint |
      ControlStyles.AllPaintingInWmPaint |
      ControlStyles.Selectable,
      true);
    this.UpdateStyles();
  }

  protected override bool IsInputKey(Keys keyData)
  {
    switch (keyData)
    {
      case Keys.Left:
      case Keys.Right:
      case Keys.Up:
      case Keys.Down:
      case Keys.PageUp:
      case Keys.PageDown:
      case Keys.Home:
      case Keys.Tab:
        return true;
    }
    return base.IsInputKey(keyData);
  }
}

